import { createApp } from 'vue'
import store from "./store"
import axios from "axios"
import App from './App.vue'
import router from "./router"


// 统一设置全局axios默认值
axios.defaults.baseURL = "http://apis.imooc.com/api"
// 添加拦截器
axios.interceptors.request.use(config => {
    // 之前的都要有，使用...展开，再添加上新的
    config.params = { ...config.params, icode: '57951175B9EC3618' }
    return config
})
axios.get('/columns?', { params: { key: 'hello' } }).then(resp => {
    console.log(resp);
})

// request 请求拦截器
axios.interceptors.request.use(config => {  
        store.commit('setLoading', true)
        return config
})
// response 响应拦截器
axios.interceptors.response.use(config => {
    store.commit('setLoading', false)
    return config
})
const app = createApp(App)
// Vue3 使用插件
app.use(router)
app.use(store)
app.mount('#app')